<html>
<head><meta charset="utf-8"><title>impls for high-rank tuples · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html">impls for high-rank tuples</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241175590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241175590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241175590">(Jun 02 2021 at 16:40)</a>:</h4>
<p>so famously traits like Debug and Ord are only implemented for tuples (and function pointers) up to arity 12. However I recently noticed that Clone is actually implemented for tuples of every arity. Presumably this is some <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> compiler magic <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> related to Copy, but I'm wondering if it's feasible/worth pursuing the same sort of magic for the other traits.</p>



<a name="241178511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241178511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241178511">(Jun 02 2021 at 17:03)</a>:</h4>
<p>magic comes at a high cost, so my first guess is that no, it wouldn't be worth it considering how rarely large tuples occur ^^</p>



<a name="241178645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241178645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241178645">(Jun 02 2021 at 17:04)</a>:</h4>
<p>I agree with Mara here -- arrays of size 64 feel way more likely than 16-tuples.</p>



<a name="241178733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241178733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241178733">(Jun 02 2021 at 17:05)</a>:</h4>
<p>So I don't feel bad about waiting for <code>min_variadic_generics</code> in a few years to get all those impls.</p>



<a name="241179166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241179166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241179166">(Jun 02 2021 at 17:08)</a>:</h4>
<p>As prior art, for example, .Net just goes to <a href="https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?view=net-5.0"><code>Tuple&lt;T1,T2,T3,T4,T5,T6,T7,TRest&gt;</code></a>.</p>



<a name="241303418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241303418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241303418">(Jun 02 2021 at 18:54)</a>:</h4>
<p>ah that's a fascinating workaround in .net, I hadn't considered that you could, to some degree, encode a high-rank tuple as a nested series of 12-tuples where the 12th element at each nesting level contains the next. if rust had a python-style unpacking operator that might even be halfway ergonomic</p>



<a name="241304638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241304638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241304638">(Jun 02 2021 at 19:04)</a>:</h4>
<p>Lisp people would say you only ever need 2-tuples <span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span></p>



<a name="241305258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impls%20for%20high-rank%20tuples/near/241305258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impls.20for.20high-rank.20tuples.html#241305258">(Jun 02 2021 at 19:09)</a>:</h4>
<p>On the other hand, Rust tuples doesn't have any inherent methods now :(  The lack of <code>min_variadic_generics</code> really makes tuples quite useless...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>